﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace MOJsdk
{
    /// <summary>
    /// Interaction logic for WindowControl.xaml
    /// </summary>
    public partial class MenuControl : UserControl
    {
        #region SettingsVars
        public double ButtonHeight { get; set; }
        public double ButtonWidth { get; set; }
        public Style ButtonStyle { get; set; }
        #endregion

        public MenuControl()
        {
            InitializeComponent();
            ButtonStyle = null;
            ButtonHeight = 20;
            ButtonWidth = 100;
        }

        public void AddNewButton(Button Btn)
        {
            try
            {
                Btn.Height = ButtonHeight;
                Btn.Width = ButtonWidth;

                Btn.Content = MOJLocalization.Localize(Btn.Content.ToString());

                if (ButtonStyle != null)
                    Btn.Style = ButtonStyle;

                _stackPanel.Children.Add(Btn);
            }
            catch (Exception ex)
            {
                MojHost.GetHost.ReportError(new ErrorReporter()
                {
                    ErrorCode = "MenuControlxAddNewBtnx01",
                    ErrorDetails = ex.ToString(),
                    ErrorMessage = "Error Adding new Button",
                });
            }
        }
        public void AddNewButton(Button Btn, int Index)
        {
            try
            {
                Btn.Height = ButtonHeight;
                Btn.Width = ButtonWidth;

                Btn.Content = MOJLocalization.Localize(Btn.Content.ToString());

                if (ButtonStyle != null)
                    Btn.Style = ButtonStyle;

                _stackPanel.Children.Insert(Index, Btn);
            }
            catch (Exception ex)
            {
                MojHost.GetHost.ReportError(new ErrorReporter()
                {
                    ErrorCode = "MenuControlxAddNewBtnx02",
                    ErrorDetails = ex.ToString(),
                    ErrorMessage = "Error Inserting new Button",
                });
            }
        }

        public int Count
        { get { return _stackPanel.Children.Count; } }
    }
}
